import { Access, useAccess } from '@/.umi/plugin-access';
import { FC, useEffect } from 'react';
import { connect, Dispatch } from 'umi';

interface Iprops {
  dispatch: Dispatch;
  name: string;
}
const Login: FC<Iprops> = (props) => {
  const { name, dispatch } = props;
  const access = useAccess();
  useEffect(() => {
    dispatch({
      type: 'login/login',
      payload: {
        userName: 'bxj',
        passwors: 'abcdefg',
      },
    });
  }, []);

  console.log('name', name);
  return (
    <div>
      <h1>登陆页面</h1>
      <Access
        accessible={access.canReadLoginContent}
        fallback={<div>Can not read login content.</div>}
      >
        login content
      </Access>
    </div>
  );
};

export default connect(({ loading, login }) => ({
  name: login.name,
}))(Login);
